home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / rexx / 661 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  6.3 KB

  1. Path: gaia.ns.utk.edu!usenet
  2. From: DBA1.CAS.UTK.EDU@   (Mychal Boyd Manie)
  3. Newsgroups: comp.lang.rexx
  4. Subject: ValueSet Object in VX REXX
  5. Date: 3 Feb 1996 04:51:18 GMT
  6. Organization: UT Knoxville
  7. Distribution: WORLD
  8. Message-ID: <4eupk6$1v2@gaia.ns.utk.edu>
  9. Reply-To: manie@utk.edu
  10. NNTP-Posting-Host: dba1.cas.utk.edu
  11. X-Newsreader: IBM NewsReader/2 v1.9d - NLS
  12.  
  13. Have you ever made a program that does some monitoring for some
  14. event (such as, network traffic patterns, lost connections, disk space exceeded)?
  15. Something you might want to see the status of at a glance.  Sort of like the
  16. "little blinky lights" on modems or network cards.  May be like a STOPLIGHT.
  17.  
  18. The "valueset" object lets you do just this.  This next segment is an extracted
  19. from a .VRT:
  20.  
  21. BEGIN         VRValueSet                                 
  22.     Border            "0"                                
  23.     ItemBorder        "0"                                
  24.     Rows              "3"                                
  25.     Columns           "1"                                
  26.     ItemType          "RGB"                              
  27.     ResizePicture     "1"                                
  28.     InitialList       ";(100,0,0);(133,121,0);(0,100,0)" 
  29.     Height            "2060"                             
  30.     Left              "241"                              
  31.     Top               "108"                              
  32.     Width             "735"                              
  33.     Visible           "1"                                
  34.     TabStop           "1"                                
  35.     Enabled           "1"                                
  36.     EventList         binary lines 0 checksum 0          
  37.     DoubleClick       ""                                 
  38.     BorderColor       "White"                            
  39.     HiliteColor       "<default>"                        
  40.     TabGroup          "0"                                
  41.     ClipSiblings      "0"                                
  42.     TabIndex          "25"                               
  43.     Font              "<default>"                        
  44.     Click             ""                                 
  45.     DragDrop          ""                                 
  46.     GotFocus          ""                                 
  47.     LostFocus         ""                                 
  48.     KeyPress          ""                                 
  49.     ForeColor         "<default>"                        
  50.     BackColor         "Black"                            
  51.     ContextMenu       ""                                 
  52.     DragTarget        "All"                              
  53.     AllowDrag         "0"                                
  54.     DragStart         ""                                 
  55.     DragIcon          ""                                 
  56.     DragDiscard       ""                                 
  57.     DragPrint         ""                                 
  58.     Name              "VS_1"                             
  59.     UserData          binary lines 0 checksum 0          
  60.     HelpText          ""                                 
  61.     HelpTag           ""                                 
  62.     HintText          ""                                 
  63. END                                                      
  64.  
  65. The above is all the field values for an arbitrary (red,yellow,green) stoplight.
  66. The default colors are a 'dimmed'  red,yellow,green.
  67.  
  68. The next segment is a procedure that I call to individually set one of the lights.
  69.  
  70. stop_light_part2:
  71. arg vs_label, item_number, color_value
  72.     call VRSet vs_label, "Selected", item_number
  73.     selected = vrget(vs_label, 'Selected')
  74.     call VRMethod vs_label, "GetAttributes", "Values", "attrs."
  75.     attrs.selected = color_value
  76.     call vrmethod vs_label,"SetAttributes","Values","attrs."
  77. return
  78.  
  79. This is the calling style for the procedure:
  80.  
  81. /*  NOTE:  'VS_1'  is the object label/title,  1,2,3 is the item number in the list
  82.     and the (x,y,z) is the RGB color values  */
  83.  
  84. call stop_light_part2 'VS_1', 1,"(255,0,0)"      /* bright red on the first item */
  85. call stop_light_part2 'VS_1', 2,"(255,255,0)"   /* bright yellow on the second item */
  86. call stop_light_part2 'VS_1', 3,"(0,255,0)"      /* bright green on the third item */
  87.  
  88. If this is a stop light, then we should probably dim the other two lights when
  89. we highlight one of them.  So enter another procedure that accepts a color (ie,
  90. RED, GREEN, YELLOW) and sets all three lights/items.
  91.  
  92. stop_light:
  93. arg color_ind
  94.  
  95.   if color_ind = 'RED' then do
  96.     call stop_light_part2 'VS_1', 1,"(255,0,0)"
  97.     call stop_light_part2 'VS_1', 2,"(133,121,0)"
  98.     call stop_light_part2 'VS_1', 3,"(0,100,0)"
  99.   end
  100.  
  101.   if color_ind = 'YELLOW' then do
  102.     call stop_light_part2 'VS_1', 1,"(100,0,0)"
  103.     call stop_light_part2 'VS_1', 2,"(255,255,0)"
  104.     call stop_light_part2 'VS_1', 3,"(0,100,0)"
  105.   end
  106.  
  107.   if color_ind = 'GREEN' then do
  108.     call stop_light_part2 'VS_1', 1,"(100,0,0)"
  109.     call stop_light_part2 'VS_1', 2,"(133,121,0)"
  110.     call stop_light_part2 'VS_1', 3,"(0,255,0)"
  111.   end
  112. return
  113.  
  114. The next question might be, "do i have to reproduce this for multiple VS objects?"
  115. Not really.  The stoplight example you might use once or so, but a simple
  116. on/off is more likely.  For that you can mainly use the first routine 
  117. (stop_light_part_2).  Rename the procs if you like.
  118.  
  119. And when calling, substitute your VS label/title (eg, 'VS_2') and the item#
  120. within the object (eg, 1,2,3) and your color scheme.  And you shouldn't have
  121. to remember the color scheme, so....
  122.  
  123. stop_light_part2_revised:
  124. arg vs_label, item_number, color_name
  125.  
  126.    color_value = '(0,0,0)'   /*  black by default or bad value  */
  127.    if color_name = 'RED' then color_value = '(255,0,0)'
  128.    if color_name = 'GREEN' then color_value = '(0,255,0)'
  129.  
  130.     call VRSet vs_label, "Selected", item_number
  131.     selected = vrget(vs_label, 'Selected')
  132.     call VRMethod vs_label, "GetAttributes", "Values", "attrs."
  133.     attrs.selected = color_value
  134.     call vrmethod vs_label,"SetAttributes","Values","attrs."
  135. return
  136.  
  137. call stop_light_part2_revised 'VS_1', 1,"RED"      
  138. call stop_light_part2_revised 'VS_1', 2,"GREEN"   
  139.  
  140. Hope you find a use for this.  Send comments to the newsgrp or to
  141. me personally.  
  142.  
  143. Extra exercise:  put the color scheme in a proc that translates
  144. all color words (eg, RED, GREEN, DULL_RED) to their respective
  145. RGB values.
  146.  
  147. ----------------------- manie@utk.edu
  148. Mychal Boyd Manie (DBA) UT Knoxville (423)974-2398
  149. WARPed... Why?  Because I have work to do (I hate rebooting).
  150.  
  151.